import { IToolTipItem } from "../../../../../com/mui/manager/IToolTipItem";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
type int = number;
//class ButtonMini
    
    export  class ButtonMini /* flash.display.Sprite */ implements IToolTipItem
    {
        constructor()
        {
            
            mouseEnabled = false;
            this.initUI();
            this.toolTipData = HTMLUtil.addColor(Language.getString(20704) + HTMLUtil.addColor("（Q）", "#00ff00"), "#ffffff");
            return;
        }

        /* internal  */onBtnMouseDownHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._down = true;
            this.updateText();
            return;
        }

        /* internal  */onBtnMouseUPHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._down = false;
            this.updateText();
            return;
        }

        /* internal  */initUI(): void
        {
            this._btn = new GButton();
            this._btn.label = "";
            this._btn.styleName = "ButtonMini";
            this._btn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onBtnMouseDownHandler);
            this._btn.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onBtnMouseUPHandler);
            addChild(this._btn);
            this._textFiled = new Object /* flash.text.TextField */();
            this._textFiled.mouseEnabled = false;
            this._textFiled.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._textFiled.width = 30;
            this._textFiled.filters = [FilterConst.nameGlowFilter];
            addChild(this._textFiled);
            return;
        }

        /* internal  */updateText(): void
        {
            if (this._down) 
            {
                this._textFiled.htmlText = HTMLUtil.addColor(this._textFiled.text, this._downColor);
            }
            else 
            {
                this._textFiled.htmlText = HTMLUtil.addColor(this._textFiled.text, this._upColor);
            }
            this._textFiled.x = this._textLeft + (this._width - this._textFiled.textWidth) / 2;
            this._textFiled.y = this._textTop + (this._height - this._textFiled.textHeight) / 2;
            return;
        }

        public set label(arg1: string)
        {
            this._textFiled.text = arg1;
            this.updateText();
            return;
        }

        public setSize(arg1: int, arg2: int): void
        {
            this._width = arg1;
            this._height = arg2;
            this._btn.setSize(arg1, arg2);
            this.updateText();
            return;
        }

        public setTextPading(arg1: int, arg2: int): void
        {
            this._textLeft = arg1;
            this._textTop = arg2;
            this.updateText();
            return;
        }

        public get toolTipData()
        {
            return this._tooltipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._tooltipData = arg1;
            return;
        }

        /* internal */ /* var */_btn: GButton;

        /* internal */ /* var */_textFiled: Object /* flash.text.TextField */;

        /* internal */ /* var */_downColor: string="#B1EFFC";

        /* internal */ /* var */_upColor: string="#B1EFFC";

        /* internal */ /* var */_down: Boolean;

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_height: int;

        /* internal */ /* var */_textLeft: int=-2;

        /* internal */ /* var */_textTop: int=-2;

        /* internal */ /* var */_tooltipData;
    }
